﻿using agsXMPP.Xml.Dom;

namespace Lapd.Common.CustomStanzas
{
    public class Write : Element
    {
        /*
         *
            <write instancename="SampleTopic">
                <samplefield datatype="long" value="1" />
                <samplefield datatype="string" value="temperature" />
                <samplefield datatype="string" value="20.0" />
	        </write>
         * 
         */

        public Write()
        {
            TagName = ServiceDdsConstants.WRITE_TAG;
        }

        public Write(string instanceName)
            : this()
        {
            InstanceName = instanceName;
        }

        public string InstanceName
        {
            get
            {
                return GetAttribute(ServiceDdsConstants.WRITE_INSTANCE_ATTRIBUTE);
            }

            set
            {
                SetAttribute(ServiceDdsConstants.WRITE_INSTANCE_ATTRIBUTE, value);
            }
        }

        public SampleField AddSampleField(SampleField sampleField)
        {
            AddChild(sampleField);
            return sampleField;
        }

        public SampleField AddSampleField(string dataType, string value)
        {
            return AddSampleField(new SampleField(dataType, value));
        }
    }
}
